#ifndef SG4C_RUNTIME_PROTOTYPE_ONLY_H_
#define SG4C_RUNTIME_PROTOTYPE_ONLY_H_

enum SG_EVENTS{
    SG_UPDATE_FRAME         = 0xee00,

    SG_SETUP_GRAPHICS       = 0xee01,


    SG_EVENT_MOUSE          = 0xee10,
    SG_EVENT_MOUSE_MOVED    = 0xee11,
    SG_EVENT_MOUSE_PRESSED  = 0xee12,
    SG_EVENT_MOUSE_ENTERED  = 0xee13,
    SG_EVENT_MOUSE_EXITED   = 0xee14,
    SG_EVENT_MOUSE_RELEASED = 0xee15,
    SG_EVENT_MOUSE_CLICKED  = 0xee16,
    SG_EVENT_MOUSE_DRAGGED  = 0xee17,

    SG_EVENT_KEY            = 0xee20,
    SG_EVENT_KEY_TYPED      = 0xee21,
    SG_EVENT_KEY_PRESSED    = 0xee22,
    SG_EVENT_KEY_RELEASED   = 0xee23,
};

enum SG_SETUP{
    SG_ENDING = 0x0fe,
    SG_SETUP_SCREEN = 0x01,
    SG_SETUP_FPS = 0x02,
    SG_SETUP_SMOOTH = 0x03,
    SG_FONT_CREATE = 0x04,
    SG_END = 0x0fe,
};

enum SG_BASIC_DRAWING_COMMANDS{


    SG_BASIC_RECT       = 0xbac01,
    SG_BASIC_ELLIPSE    = 0xbac02,
    SG_BASIC_LINE       = 0xbac03,
    SG_BASIC_POINT      = 0xbac04,
    SG_BASIC_POLYGON    = 0xbac05,

    SG_BASIC_TRANSLATE  = 0xbac06,
    SG_BASIC_ROTATE     = 0xbac07,

    SG_BASIC_FONT       = 0xbac08,
    SG_BASIC_TEXT       = 0xbac09,

    SG_BASIC_STROKE     = 0xbac0a,
    SG_BASIC_FILLCOLOR  = 0xbac0b,
    SG_BASIC_STROKECOLOR = 0xbac0c,
    SG_BASIC_NOFILL     = 0xbac0d,


    SG_BASIC_END        = SG_END,
};

typedef unsigned char byte_t;

void sgFlush();


////////////////////////////////////////////////////////////////////////
// Setup
//

typedef void (*sg_callback_t)(void);

typedef struct {
    struct{ int width, height; } screen;
    int framerate;
    int smooth;


    sg_callback_t setup;
    sg_callback_t draw;

    //mouse events
    sg_callback_t mouseMoved;
    sg_callback_t mousePressed;
    sg_callback_t mouseReleased;
    sg_callback_t mouseClicked;
    sg_callback_t mouseEntered;
    sg_callback_t mouseExited;
    sg_callback_t mouseDragged;

    //key events
    sg_callback_t keyTyped;
    sg_callback_t keyPressed;
    sg_callback_t keyReleased;


    //redraw?
    int _redraw;
} sg_config_t;

void sgInitConfig(sg_config_t * p);
int sgWidth();
int sgHeight();
void sgSetupScreen();
void sgSetupFramerate();
void sgEndSetup();
void sgSetupSmooth();
void sgSetup(const sg_config_t * config);
void sgEndSetupGraphics();
////////////////////////////////////////////////////////////////////////
// Key Event
//

typedef struct{
    int character;
    int code;
} sg_key_t;

sg_key_t sgKey();
sg_key_t sgKeyPrevious();

////////////////////////////////////////////////////////////////////////
// Mouse Event
//
typedef struct {
    int x;
    int y;
    int button;
} sg_mouse_t;


sg_mouse_t sgMouse();
sg_mouse_t sgMousePrevious();


////////////////////////////////////////////////////////////////////////
// Graphics
//

typedef struct {
    byte_t red, green, blue, alpha;
} color_t;

void sgRedraw();
color_t sgRGBA(byte_t r, byte_t g, byte_t b, byte_t a );
color_t sgRGB(byte_t r, byte_t g, byte_t b);
color_t sgGray(byte_t gray );
color_t sgHexRGB( unsigned int rgb );
color_t sgHexRGBA( unsigned int rgb );

void sgRect(int x, int y, int w, int h);
void sgEllipse(int x, int y, int w, int h);
void sgLine(int x1, int y1, int x2, int y2);
void sgPoint(int x, int y);
void sgStroke(color_t color);
void sgStrokeWeight(float weight);
void sgNoStroke();
void sgNoFill();
void sgFill(color_t color);
void sgPolygon(int npoints, ... );
void sgPolygonArray( int xpos[], int ypos[], int npoints );
void sgTranslate( int x, int y );
void sgRotate( float angle );
void sgEndGraphics();

////////////////////////////////////////////////////
// Font
//
typedef struct {
    int __id;
    int height;
} sg_font_t;


sg_font_t sgCreateFont( char * fontname, int pt );

void sgFont(sg_font_t font);
void sgText(const char * text, int x, int y);
////////////////////////////////////////////////////////////////////////

int sgRunForever();

#endif  //SG4C_RUNTIME_PROTOTYPE_ONLY_H_
